package com.dayu.controller;

import com.dayu.model.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.management.Query;

@Api(tags = "测试swagger2类")
@RestController
public class TestController {

    @RequestMapping(value = "/testGetSwagger2", method = RequestMethod.GET)
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "username", value = "用户名", defaultValue = "李四", paramType = "Query"),
//            @ApiImplicitParam(name = "address", value = "用户地址", defaultValue = "深圳", required = true, paramType = "Query")
//    })
    @ApiOperation("测试swagger2的testSwagger2接口")
    public String test(@RequestParam String username, @RequestParam String address) {
        System.out.println(username + ":" + address);
        return "测试接口进入成功";
    }

    @RequestMapping(value = "/testPostSwagger2", method = RequestMethod.POST)
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "username",dataType = "body",defaultValue = "dayu"),
//            @ApiImplicitParam(name = "address",dataType = "body",defaultValue = "dayu")
//    })
    @ApiOperation("测试swagger2的testSwagger2post接口")
    public String test(@RequestBody User user) {
        System.out.println(user);
        return "测试接口进入成功";
    }

    @RequestMapping(value = "/testUrlSwagger2/{id}", method = RequestMethod.GET)
    @ApiOperation("测试swagger2的testSwagger2url接口")
//    @ApiImplicitParam(name = "id", value = "用户id", defaultValue = "100", paramType = "path", dataType = "Long", required = true)
    public String test(@PathVariable("id") Long id) {
        System.out.println(id);
        return "测试接口进入成功";

    }
}
